f13ce558cc410f959634a6f0d31fcf7bd69be85d,src/java/org/apache/cassandra/io/sstable/CQLSSTableWriter.java,Builder,forTable,#String#,335

Before Change



                // We need to register the keyspace/table metadata through Schema, otherwise we won't be able to properly
                // build the insert statement in using().
                KSMetaData ksm = KSMetaData.newKeyspace(this.schema.ksName,
                                                        AbstractReplicationStrategy.getClass("org.apache.cassandra.locator.SimpleStrategy"),
                                                        ImmutableMap.of("replication_factor", "1"),
                                                        true,
                                                        Collections.singleton(this.schema));

                Schema.instance.load(ksm);
                return this;

After Change


        {
            try
            {
                synchronized (CQLSSTableWriter.class)
                {
                    this.schema = getStatement(schema, CreateTableStatement.class, "CREATE TABLE").left.getCFMetaData().rebuild();

                    // We need to register the keyspace/table metadata through Schema, otherwise we won't be able to properly
                    // build the insert statement in using().
                    KSMetaData ksm = Schema.instance.getKSMetaData(this.schema.ksName);
                    if (ksm == null)
                    {
                        ksm = KSMetaData.newKeyspace(this.schema.ksName,
                                AbstractReplicationStrategy.getClass("org.apache.cassandra.locator.SimpleStrategy"),
                                ImmutableMap.of("replication_factor", "1"),
                                true,
                                Collections.singleton(this.schema));
                        Schema.instance.load(ksm);
                    }
                    else if (Schema.instance.getCFMetaData(this.schema.ksName, this.schema.cfName) == null)
                    {
                        Schema.instance.load(this.schema);
                        ksm = KSMetaData.cloneWith(ksm, Iterables.concat(ksm.cfMetaData().values(), Collections.singleton(this.schema)));
                        Schema.instance.setKeyspaceDefinition(ksm);
                        Keyspace.open(ksm.name).initCf(this.schema.cfId, this.schema.cfName, false);
                    }
                    return this;
                }